// File contains functions for loading from and saving to text. 

if (typeof SudokuUI === 'undefined') var SudokuUI = {};

SudokuUI.textIO = 
{
	// Convert a grid to text and displaying it in a textarea
	displayOutput : function (grid)
	{
		var TArea = document.getElementById('sudoku_text');
		TArea.style.display = '';
		TArea.value = grid.toLocaleString();
		TArea.select();

		document.getElementById('sudoku_text_button').style.display = 'none';
	},

	// Hide the textarea
	hideDisplay : function ()
	{
		document.getElementById('sudoku_text').style.display = 'none';
		document.getElementById('sudoku_text_button').style.display = 'none';
	},

	// Display the textarea allowing user to paste a clue grid
	prepareInput : function ()
	{
		var TArea = document.getElementById('sudoku_text');
		TArea.style.display = '';
		TArea.value = '';
		TArea.focus();

		document.getElementById('sudoku_text_button').style.display = '';
	},

	// Load clue grid from the textarea
	loadInput : function ()
	{
		document.getElementById('sudoku_text_button').style.display = 'none';

		var TArea = document.getElementById('sudoku_text');
		if (TArea.value) SudokuUI.controller.loadPuzzle(TArea.value);
		TArea.style.display = 'none';
	}
}
